<template>
	<view class="container">
		<view class="warpper">
			<list-cell title="Total" icon="el-icon-money" :tips="order_amount" tipsSize="28rpx" tipsColor="#333333" navigateType="null"></list-cell>
			<list-cell imgUrl="/static/images/fomo.png" title="FOMO Pay" @eventClick="payment()"></list-cell>
		</view>
	</view>
</template>

<script>
	import listCell from '@/components/mix-list-cell';
	import {apiUrl} from '../../config/config'
	import {builderUrlParams} from '../../config/common'
	export default {
		components: {
			listCell
		},
		data() {
			return {
				order_no: '',
				id: null,
				order_info: ''
			}
		},
        computed: {
            order_amount() {
                if (this.order_info.order_amount) {
                    return 'SGD $ ' +  " "  + this.order_info.order_amount
                }
                return 'SGD $ ' +  " "  + 0.00
            }
        },
		onLoad(options) {
			if(options.id) {
				this.id = options.id
			}
			if(options.order_no) {
				this.order_no = options.order_no
			}
			this.loadData();
		},
		onShow() {
			this.loadData();
		},
		methods: {
			payment() {
				let url = builderUrlParams(apiUrl + 'api/mall/payment/pay', {
					order_no: this.order_no
				})

                // 去支付
				plus.runtime.openURL(url);

				setTimeout(() => {
					// 跳转到支付结果页
					this.$common.navigateTo('../public/payResult', {
						order_no: this.order_no
					});
				}, 2000)
			},
			loadData() {
				let _this = this
				// 数据加载
				this.$api.orderDetail({
					id: this.id,
					order_no: this.order_no
				}, res => {
					this.order_info = res.data
					this.order_no = res.data.order_no
				})
			}
		}
	}
</script>

<style lang="scss">
.cell-tip {
    fontSize:200px
}
</style>
